home *** CD-ROM | disk | FTP | other *** search
- Path: news.th-darmstadt.de!news
- From: Enno Sandner <enno@intellektik.informatik.th-darmstadt.de>
- Newsgroups: comp.lang.c++
- Subject: Re: class self destuction???
- Date: Wed, 21 Feb 1996 13:56:39 +0100
- Organization: Fachbereich Informatik, TH Darmstadt
- Message-ID: <312B1687.41C67EA6@intellektik.informatik.th-darmstadt.de>
- References: <1996Feb20.152904.13555@alw.nih.gov>
- NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (X11; I; SunOS 4.1.3 sun4m)
-
- Dean Fuqua wrote:
- >
- > I was wondering what the *correct* method of class suicide is.
- > For example, while in a member function, a class realizes that
- > it is no longer wanted in little computing world and that it should
- > kill itself.
- >
- > Should it call it own destuctor and that's that or should it do delete(this).
- > The delete method seems a bit dangerous to me.
- >
-
- Hmm, what do you expect ? -- suicide in the real world seems also
- quite dangerous to me ;-)
- If you use 'delete this;' the object must have been created via 'new'.
- In addition you must not access any (non-static) member after the
- object has been destructed. If you can guarantee that this requirements
- are not violated there is no problem in using 'delete this'.
-
- Enno
-